//
//  ContactManger.m
//  04-集合（2）
//
//  Created by 韩旭 on 16/7/7.
//  Copyright © 2016年 基础. All rights reserved.
//

#import "ContactManger.h"

@implementation ContactManger
- (instancetype)initWithDictionary:(NSMutableDictionary *)dictionary {
    self = [super init];
    if (self) {
        _dicManger = dictionary;
    }
    return self;
}
- (void)addContact:(Contact *)contact {
    if (contact.name.length > 0 && contact.phoneNumber.length > 0) {
        NSMutableArray *contactArr = [_dicManger objectForKey:contact.groupName];
        if (contactArr == nil) {
            contactArr = [NSMutableArray arrayWithObject:contact];
            [_dicManger setObject:contactArr forKey:contact.groupName];
        } else {
            [contactArr addObject:contact];
        }
        NSLog(@"添加联系人%@", contact.name);
    } else {
        NSLog(@"%@添加失败", contact.name);
    }
}
//- (void)delegateContact:(Contact *)contact {
//
//}
- (void)removeGroupWithGroupName:(NSString *)groupName {
    [_dicManger removeObjectForKey:groupName];
}
@end
